home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / mactool / thinkcgu.sit / TC Prog Guide / card_50447.txt < prev    next >
Encoding:
Text File  |  1991-02-27  |  646 b   |  27 lines

  1. -- card: 50447 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. SIMULATING 'ELSE IF'
  11.  
  12. The 'else if' statement available in other languages is easily simulated using nested 'if' statements and the appropriate use of white space:
  13.  
  14.     if (i == 0)
  15.         result = 'a';
  16.     else if (i == 1 || i == 2)
  17.         result = 'b';
  18.     else if (i == 3)
  19.         result = 'c';
  20.     else
  21.         result = 'd';
  22.  
  23. An alternative which is often appropriate is the 'switch' statement discussed in the next section.
  24.  
  25. -- part contents for background part 7
  26. ----- text -----
  27. 158